<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>The Page Request Cycle | Raxan User Guide</title>
    <link href="../raxan/styles/master.css" rel="stylesheet" type="text/css" />
    <!--[if IE]><link rel="stylesheet" href="../raxan/styles/master.ie.css" type="text/css"><![endif]-->
    <link href="style.css" rel="stylesheet" type="text/css" />
    <link href="highlight/styles/default.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="highlight/highlight.js"></script>
    <script type="text/javascript">
        hljs.initHighlightingOnLoad('javascript','html','php');
    </script>

</head>

<body>
    <div class="container c48 prepend-top">
        <h2 class="bottom">Raxan User Guide</h2>
        <div class="navbar">
            <div class="lf"><div class="rt"><div class="md">
                <ul>
                    <li><a href="../index.html" title="The Rich Ajax, CSS &amp; PHP Framework" >Home</a></li>
                    <li><a href="table-of-contents.html" title="Blog Posts" >Table Of Contents</a></li>
                    <li><a href="../php-examples/index.php" title="PHP Examples" >PHP Examples</a></li>
                    <li><a href="../css-examples/index.html" title="User Guide" >CSS Examples</a></li>
                </ul>
            </div></div></div>
        </div>
        <div class="prepend1 append1">
            <div class="ltm" align="right">
                <a href="table-of-contents.html" title="Show Table of Content">
                    <img src="images/toc-button.png"  alt="Table of Contents" />
                </a>
            </div>
            <h2>The Page Request Cycle</h2>

<div align="center" class="pad">
    <img src="images/pdi-request.gif" />
</div>

<p>When a client makes a request to view a web page, the framework will load your Page-Controller logic and allow you to load and process your html views using simple css selectors (for example #id, .classname, etc). Once processing is completed, a reply is sent back to the client that made the request. The replied text contains your html code and may include embedded javascript/css stylesheet.</p>

<p>If a request was made via an ajax call, then a JSON object is returned to the client. The returned JSON object may include the action scripts (a mixed of jQuery and JavaScripts) needed to carry out a specific task within the client's web browser.</p>

<h4>Synchronous Page Request Execution</h4>

<ul>
<li>Init - Called after the page object is created. Used for initializing connections and loading page source</li>
<li>Authorize - Used to secure or grant access to the page</li>
<li>Switchboard - Called whenever a switchboard action is requested. </li>
<li>Load - Used for loading additional views/content into web page.</li>
<li>Custom Event Request Handler - Triggers the event raised by client</li>
<li>PreRender - Used for making final modifications to page just before html is extracted from the DOM</li>
<li>PostRender - Called after the HTML is extracted from the DOM and all external and internal processing have been completed</li>
<li>Reply - Called just after the content is sent back to the client.</li>
<li>Finalize - Called before the page object is destroyed; Can be used to close open connections etc</li>
</ul>

<h4>Asynchronous (AJAX) Page Request Execution</h4>

<ul>
<li>Init - Called after the page object is created. Used for initializing connections and loading page source</li>
<li>Authorize - Used to secure or grant access to the page</li>
<li>Switchboard - Called whenever a switchboard action is requested. </li>
<li>Load - Used for loading additional views/content into web page.</li>
<li>Custom Event Request Handler - Triggers the event raised by client</li>
<li>Reply - Called just after the JSON content is sent back to the client.</li>
<li>Finalize - Called before the page object is destroyed; Can be used to close open connections etc</li>
</ul>

<h4>Data Reset handler</h4>

<ul>
<li>Reset - This handler is called before the page data storage is reset. The RaxanWebPage->resetOnFirstLoad property must be set to true in order for the data to be reset on first load</li>
</ul>

<p>Page event handler are prefixed with an "_" as shown in the example below:</p>

<pre><code>&lt;?php
    require_once('raxan/pdi/autostart.php');

    class NewPage extends RaxanWebPage {

        protected function _init() {
            $this-&gt;append('* This is the init handler &lt;br /&gt;');
        }

        protected function _load() {
            $this-&gt;append('* This is the load handler &lt;br /&gt;');
        }

        protected function _prerender() {
            $this-&gt;append('* This is the prerender handler &lt;br /&gt;');
        }

    }
?&gt;
</code></pre>

<hr />

<p><a href="connecting-dots.html">Connecting The Dots >></a></p>

        </div>
        <div class="tpb pad" style="text-align:right">
            <div class="right ltm">
                <a href="table-of-contents.html" title="Back to Table of Content">
                    <img src="images/toc-button.png"  alt="Table of Contents" />
                </a>
            </div>
        </div>
    </div>
</body>

</html>

